<%--
  Created by IntelliJ IDEA.
  User: 几何
  Date: 2022/4/20
  Time: 21:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<html>
<head>
    <title>Title</title>
</head>
<script type="text/javascript">
    function as(data1,data2){
        var but = document.getElementById(data1);
        $.ajax({
            url:"http://localhost:8081/ajaxuser/updateattention",
            data:{"userId":data2,"topicId":data1},
            success:function (data){
                if(data) but.value = "关注"
                else     but.value="取消关注"
            }
        })
    }
</script>
<body>
<c:forEach var="item" items="${topics}">
    <a href="${pageContext.request.contextPath}/userfunction/queryTopic?id=${item.topicId}">
            话题：<span>${item.topicName}</span>
            粉丝：<span>${item.topicAttention}</span>
    </a>
    <input type="button" id="${item.topicId}" name="${userid}"  onclick="as(this.id,this.name)" value="取消关注"><br/>
</c:forEach>
</body>
</html>
